<?php
class ApiAction extends Action{
	
	public function weixin(){
		ob_get_clean();
		$WX =  D('Weixin');		
		
		// 验证消息真实性
		//if($rst = $WX->valid()){
			//exit($rst);
		//}
		
		//接受消息
		$WX->responseMsg();
	}
	 public function uploadify(){
	  
	    $verifyToken = md5('unique_salt' . $_POST['timestamp']);
		if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
			import('ORG.Net.UploadFile');
			$upload = new UploadFile();// 实例化上传类
			$upload->maxSize  = 3145728 ;// 设置附件上传大小
			$upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
			$upload->savePath =  './Upload/images';// 设置附件上传目录
			$upload->autoSub = true;
			$upload->subType = 'date';
			if(!$upload->upload()) {// 上传错误提示错误信息
				$return['status'] = 0;
				$return['info'] = $upload->getErrorMsg();
				
			}else{
				// 上传成功 获取上传文件信息
				$info =  $upload->getUploadFileInfo();
				$return['status'] = 1;
				$return['info'] = $info;
			
			}
			echo json_encode($return);exit;
	   }else{
		   $return['status'] = 0;
			$return['info'] = '不合法的请求';
			echo json_encode($return);exit;
	   }
	}
    public function uploadFile(){

        import('ORG.Net.UploadFile');
        $upload = new UploadFile();// 实例化上传类
        $upload->maxSize  = 3145728 ;// 设置附件上传大小
        $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->savePath =  './Upload/images/';// 设置附件上传目录
        $upload->autoSub = true;
        $upload->subType = 'date';
        if(!$upload->upload()) {// 上传错误提示错误信息
            $return['status'] = 0;
            $return['info'] = $upload->getErrorMsg();

        }else{
            // 上传成功 获取上传文件信息
            $info =  $upload->getUploadFileInfo();
            $return['status'] = 1;
            $return['info'] = $info;

        }
        echo json_encode($return);exit;
    }
	
}